<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@include file="/jsp/commons/header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>销售分析系统</title>
     <link rel="stylesheet" type="text/css" media="screen" href="${ctx }/resources/css/regesiter-style.css" />
     <%@ include file="/jsp/commons/meta.jsp"%>
     <script type="text/javascript">
         $(function(){
             $("#regesiter_form").validate({
            	    rules:{
                        loginId:{
                            required:true,
                            minlength:3,
                            remote:{
                                type:"post",
                                url:"${ctx}/user/validateLoginId.htm",
                                data:{
                                    loginId:function(){
                                        return $("#txtUsername").val();
                                    }
                                }
                            }
                        },
                        password:{
                            required:true,
                            minlength:5
                        },
                        cpassword:{
                            required:true,
                            equalTo:"#txtPassword"
                        },
                        email:{
                            required:true,
                            email:true
                        }
                    },
                    messages:{
                        loginId:{
                        	required:"请输入",
                        	minlength:"用户名的长度至少为3个字符",
                            remote:"账号已经存在"
                        },
                        password:{
                        	required:"请输入",
                        	minlength:"密码的长度至少为5个字符"
                        },
                        cpassword:{
                        	required:"请输入",
                        	equalTo:"确认密码与密码输入不一致"
                        },
                        email:{
                        	required:"请输入",
                        	email:"您输入的Email格式不正确"
                        }
                    },
                    submitHandler: function(form) {
                    	 $.ajax({
                    		type:"POST",  
                            url: "${ctx}/user/regesiterUser.htm",
                            data: {
                                  loginId:$("#txtUsername").val(),
                                  password:$("#txtPassword").val(),
                                  email:$("#txtEmail").val()
                              },
                    	    success: function(result){
                    	    	$("#status").html("注册成功，正在跳转...");
                    	    	window.location.href="${ctx}/user/toLogin.htm";
                            }
                         });
                    }
             });
             $("#login").click(function(){
                 window.location.href="${ctx}/user/toLogin.htm";
             });
         });
     </script>
</head>
<body>
    <div id="regesiter">
        <div id="regesiterLogo"></div>
        <div id="regesiterPanel">
            <div class="panel-h"></div>
            <div class="panel-c">
                <div class="panel-c-l">
                    <form id="regesiter_form" action="${ctx}/user/regesiterUser.htm" method="post">
                        <table cellpadding="0" cellspacing="0">
                        
                            <tbody>
                                <tr>
                                    <td align="left" colspan="2"> 
                                        <div id="status"></div>
                                        <h3>用户信息注册</h3>
                                    </td>
                                </tr> 
                                <tr>
                                    <td align="right">账号：</td>
                                    <td align="left"><input type="text" name="loginId" id="txtUsername" class="regesiter-text" /></td>
                                </tr>
                                <tr>
                                    <td align="right">密码：</td>
                                    <td align="left"><input type="password" name="password" id="txtPassword" class="regesiter-text" /></td>
                                </tr>
                                <tr>
                                    <td align="right">密码确认：</td>
                                    <td align="left"><input type="password" name="cpassword" id="txtCPassword" class="regesiter-text" /></td>
                                </tr> 
                                <tr>
                                    <td align="right">E-mail：</td>
                                    <td align="left"><input type="text" name="email" id="txtEmail" class="regesiter-text" /></td>
                                </tr> 
                                <tr>
                                    <td></td>
                                    <td align="left">
                                        <input type="submit" id="submitBtn" value="注册" class="regesiter-btn" />
                                    </td>
                                    
                                </tr> 
                            </tbody>
                            
                        </table>
                    </form>
                </div>
                <div class="panel-c-r">
                    <p>请从左侧输入注册的相关信息</p>
                    <p>如果遇到系统问题，请联系系统管理员。</p>
                    <p>如果已有账号，请直接登录 </p>
                    <div id= "login"><h3 align="center">登&nbsp;录</h3></div>
                </div>
            </div>
            <div class="panel-f"></div>
        </div>
        <div id="regesiterCopyright">Copyright © 2012 迪士恩 </div>
    </div>
</body>
